<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    
</body>
<script>

    class Parent{
        constructor(m){
            this.msg = m
        }
        show(){
            console.log(this.msg);
        }
    }

    // 创建子类时使用extends关键字指定要继承的父类
    class Child extends Parent{
        constructor(m){
            // 在子类的构造函数内，执行super方法，如果有参数，由super传给父类
            super(m);
        }
        show(){
            console.log("Child的show")
        }
    }

    const p = new Parent("hello");
    console.log(p);
    p.show();
    

    const c = new Child("world");
    console.log(c)
    c.show();

    // 子类是父类的子类
    // 父类是子类的超类

</script>
</html>